package April._23.work4;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.concurrent.Callable;

public class MyCallable implements Callable<String> {
    File filePath;
    File copyPath;

    public MyCallable(File filePath, File copyPath) {
        this.filePath = filePath;
        this.copyPath = copyPath;
    }

    @Override
    public String call() throws Exception {
        FileInputStream in = new FileInputStream(filePath);
        FileOutputStream out = new FileOutputStream(copyPath);
        int readCount;
        byte[] bytes = new byte[1024];
        while ((readCount=in.read(bytes))!=-1){
            out.write(bytes,0,readCount);
        }
        return Thread.currentThread().getName()+"复制完成";
    }
}
